﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Start : System.Web.UI.Page
{
    private static Game game;

    protected void Page_Load(object sender, EventArgs e)
    {
       
    }

    public void UpdateForm()
    {
        ListBox1.Items.Clear();
        foreach (Card card in game.GetPlayerCardNames())
            ListBox1.Items.Add(card.Rank + " of " + card.Suit);
        txtBooks.Text = game.DescribeBooks();
    
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (game.Play(Convert.ToInt32(txtCard.Text), txtPlayer.Text))
        {
            txtGameMoves.Text += "The winner is... ";
            txtGameMoves.Text = game.DescribeBooks();
            Button1.Enabled = false;
        }
        else
            UpdateForm();
        }

    protected void Button2_Click(object sender, EventArgs e)
    {
        //Player joined to listbox
        txtGameMoves.Text += User.Identity.Name.ToString() + " joined the game." + Environment.NewLine;

        game = new Game(User.Identity.Name.ToString(), new List<string> { "Joe", "Bob" });
        UpdateForm();
    }
}